<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var str = 'xxyyaaddkkiieess',
				reg = /(\w)\1(\w)\2/g;
			
			var str2 = str.replace(reg, function($, $1, $2){
				return $2 + $2 + $1 + $1;
			})
			
		</script>
	</body>
</html>
